package main

import (
	"flag"
	"log"
	"runtime"
	"tcptemplate/config"
	"tcptemplate/logger"
	"tcptemplate/network"
)

func main() {
	if runtime.GOOS != `linux` {
		log.Print("do not support " + runtime.GOOS + " platform")
		//return
	}
	var confPath string
	flag.StringVar(&confPath, "conf_path", "TcpServConfig.json", "the path of configuration file")
	flag.Parse()
	config.InitConfig(confPath)

	//network.SetHandler(handler.HandlePack)
	server := network.ServerFactory(config.Configs().Ipadress)
	server.SetHandler(nil)
	log.Print("start " + config.Configs().Type + " server " + "at address " + config.Configs().Ipadress)
	e := server.Run()
	if nil != e {
		logger.LogDebugError(e.Error())
	}
}
